package shemes;

import gui.GuiLabel;
import gui.GuiLine;
import gui.GuiScheme;

import java.awt.Point;
import java.util.ArrayList;

import components.*;

public class Exec1 {

    private static TSB TSBALUout1, TSBABout2;
    private static IntToInt ABLToAB, IBUS2ToALU;
    private static ALU ALUexec;
    private static IntToBools ALUbits, ABbits, BBbits;
    private static IntToInt IBUS1ToAB, IBUS2ToBB;
    private static TSB TSBBBout2;
    private static REG AB, BB;
    private static MP MX3, MX4;
    private static CD CD1, CD2;
    private static TSB TSBAWHout2, TSBAWout2, TSBBWout1;
    private static IntToInt AWToAWH;
    private static REG AW, BW;
    private static GuiScheme gui;

    public static GuiScheme getGui() {
        return gui;
    }

    public static void init() {

        TSBALUout1 = new TSB();
        TSBALUout1.getOut(0).setNumOfLines(8);

        ABLToAB = new IntToInt(8, 16, false, false);
        TSBABout2 = new TSB();
        TSBABout2.getOut(0).setNumOfLines(16);

        ALUexec = new ALU();
        ALUbits = new IntToBools(8, 8);
        ABbits = new IntToBools(8, 8);
        BBbits = new IntToBools(8, 8);

        IBUS1ToAB = new IntToInt(16, 8, false, false);
        IBUS2ToBB = new IntToInt(16, 8, false, false);
        IBUS2ToALU = new IntToInt(16, 8, false, false);

        TSBBBout2 = new TSB();
        TSBBBout2.getOut(0).setNumOfLines(8);

        AB = new REG(1, "AB");
        AB.getOut(0).setIsInt();
        AB.getOut(0).setNumOfLines(8);

        BB = new REG(1, "BB");
        BB.getOut(0).setIsInt();
        BB.getOut(0).setNumOfLines(8);

        MX3 = new MP(4);
        CD1 = new CD(4);
        CD1.setE(new Pin(true));

        MX4 = new MP(4);
        CD2 = new CD(4);
        CD2.setE(new Pin(true));

        TSBBWout1 = new TSB();
        TSBBWout1.getOut(0).setNumOfLines(16);

        AWToAWH = new IntToInt(16, 8, false, true);
        TSBAWHout2 = new TSB();
        TSBAWHout2.getOut(0).setNumOfLines(8);

        TSBAWout2 = new TSB();
        TSBAWout2.getOut(0).setNumOfLines(16);

        AW = new REG(1, "AW");
        AW.getOut(0).setIsInt();
        AW.getOut(0).setNumOfLines(16);
        BW = new REG(1, "BW");
        BW.getOut(0).setIsInt();
        BW.getOut(0).setNumOfLines(16);

    }

    public static void connect() {

        TSBALUout1.setInputPin(0, ALUexec.getOut(0));
        TSBALUout1.setCtrl(Oper1.ALUout1());
        Bus1.addOnIBUS1(TSBALUout1.getOut(0));

        ABLToAB.setInputPin(0, AB.getOut(0));
        TSBABout2.setInputPin(0, ABLToAB.getOut(0));
        TSBABout2.setCtrl(Oper1.ABout2());
        Bus1.addOnIBUS2(TSBABout2.getOut(0));

        IBUS2ToALU.setInputPin(0, Bus1.IBUS2());
        ALUexec.setPinX(AB.getOut(0));
        ALUexec.setPinY(IBUS2ToALU.getOut(0));
        ALUexec.setPinAdd(Oper1.add());
        ALUexec.setPinSub(Oper1.sub());
        ALUexec.setPinInc(Oper1.inc());
        ALUexec.setPinDec(Oper1.dec());
        ALUexec.setPinAnd(Oper1.and());
        ALUexec.setPinOr(Oper1.or());
        ALUexec.setPinXor(Oper1.xor());
        ALUexec.setPinNot(Oper1.not());
        ALUbits.setInputPin(0, ALUexec.getOut(0));

        IBUS1ToAB.setInputPin(0, Bus1.IBUS1());
        IBUS2ToBB.setInputPin(0, Bus1.IBUS2());

        TSBBBout2.setInputPin(0, BB.getOut(0));
        TSBBBout2.setCtrl(Oper1.BBout2());
        Bus1.addOnIBUS2(TSBBBout2.getOut(0));

        AB.setInputPin(0, IBUS1ToAB.getOut(0));
        AB.setPinLd(Oper1.ldAB());
        AB.setShr(Oper1.shr());
        AB.setIR(MX3.getOut(0));
        AB.setShl(Oper1.shl());
        AB.setIL(MX4.getOut(0));
        ABbits.setInputPin(0, AB.getOut(0));

        BB.setInputPin(0, IBUS2ToBB.getOut(0));
        BB.setPinLd(Oper1.ldBB());
        BBbits.setInputPin(0, BB.getOut(0));

        CD1.setInputPin(0, Fetch2.ASR());
        CD1.setInputPin(1, Fetch2.LSR());
        CD1.setInputPin(2, Fetch2.ROR());
        CD1.setInputPin(3, Fetch2.RORC());
        MX3.setCtrl(0, CD1.getOut(0));
        MX3.setCtrl(1, CD1.getOut(1));
        MX3.setInputPin(0, ABbits.getOut(7));
        MX3.setInputPin(1, new Pin(false));
        MX3.setInputPin(2, ABbits.getOut(0));
        MX3.setInputPin(3, Exec2.PSWC());

        CD2.setInputPin(0, Fetch2.ASL());
        CD2.setInputPin(1, Fetch2.LSL());
        CD2.setInputPin(2, Fetch2.ROL());
        CD2.setInputPin(3, Fetch2.ROLC());
        MX4.setCtrl(0, CD2.getOut(0));
        MX4.setCtrl(1, CD2.getOut(1));
        MX4.setInputPin(0, new Pin(false));
        MX4.setInputPin(1, new Pin(false));
        MX4.setInputPin(2, ABbits.getOut(7));
        MX4.setInputPin(3, Exec2.PSWC());

        TSBBWout1.setInputPin(0, BW.getOut(0));
        TSBBWout1.setCtrl(Oper1.BWout1());
        Bus1.addOnIBUS1(TSBBWout1.getOut(0));

        AWToAWH.setInputPin(0, AW.getOut(0));
        TSBAWHout2.setInputPin(0, AWToAWH.getOut(0));
        TSBAWHout2.setCtrl(Oper1.AWHout2());
        Bus1.addOnIBUS2(TSBAWHout2.getOut(0));

        TSBAWout2.setInputPin(0, AW.getOut(0));
        TSBAWout2.setCtrl(Oper1.AWout2());
        Bus1.addOnIBUS2(TSBAWout2.getOut(0));

        AW.setInputPin(0, Bus1.IBUS1());
        AW.setPinLd(Oper1.ldAW());
        BW.setInputPin(0, Bus1.IBUS1());
        BW.setPinLd(Oper1.ldBW());
    }

    public static void gui() {
        GuiLine line; // Pomocna promenljiva
        gui = new GuiScheme("src/images/Exec1.png");

        ArrayList<ArrayList<Point>> sections;
        ArrayList<Point> points;



        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(66, 52));
        points.add(new Point(66, 872));
        sections.add(points);
        points = new ArrayList<Point>();
        points.add(new Point(68, 52));
        points.add(new Point(68, 872));
        sections.add(points);
        line = new GuiLine(sections, Bus1.IBUS1());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(632, 52));
        points.add(new Point(632, 872));
        sections.add(points);
        points = new ArrayList<Point>();
        points.add(new Point(634, 52));
        points.add(new Point(634, 872));
        sections.add(points);
        line = new GuiLine(sections, Bus1.IBUS2());
        gui.addLine(line);

        BoolsToInt zeroes = new BoolsToInt(8, 8);
        for (int i = 0; i < 7; i++) {
            zeroes.setInputPin(i, new Pin(false));
        }

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(409, 83));
        points.add(new Point(438, 83));
        sections.add(points);
        line = new GuiLine(sections, zeroes.getOut(0));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(409, 99));
        points.add(new Point(438, 99));
        sections.add(points);
        line = new GuiLine(sections, AB.getOut(0));
        gui.addLine(line);
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(478, 91));
        points.add(new Point(520, 91));
        sections.add(points);
        line = new GuiLine(sections, ABLToAB.getOut(0));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(532, 96));
        points.add(new Point(532, 104));
        sections.add(points);
        line = new GuiLine(sections, Oper1.ABout2());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(544, 91));
        points.add(new Point(631, 91));
        sections.add(points);
        line = new GuiLine(sections, TSBABout2.getOut(0));
        gui.addLine(line);


        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(151, 653));
        points.add(new Point(159, 653));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.ASR());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(151, 632));
        points.add(new Point(159, 632));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.LSR());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(151, 612));
        points.add(new Point(159, 612));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.ROR());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(151, 591));
        points.add(new Point(159, 591));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.RORC());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(221, 632));
        points.add(new Point(241, 632));
        points.add(new Point(241, 550));
        points.add(new Point(200, 550));
        points.add(new Point(200, 540));
        sections.add(points);
        line = new GuiLine(sections, CD1.getOut(0));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(221, 612));
        points.add(new Point(231, 612));
        points.add(new Point(231, 561));
        points.add(new Point(180, 561));
        points.add(new Point(180, 540));
        sections.add(points);
        line = new GuiLine(sections, CD1.getOut(1));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(151, 520));
        points.add(new Point(159, 520));
        sections.add(points);
        line = new GuiLine(sections, Exec1.AB7());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(151, 499));
        points.add(new Point(159, 499));
        sections.add(points);
        line = new GuiLine(sections, new Pin(false));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(151, 479));
        points.add(new Point(159, 479));
        sections.add(points);
        line = new GuiLine(sections, Exec1.AB0());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(151, 458));
        points.add(new Point(159, 458));
        sections.add(points);
        line = new GuiLine(sections, Exec2.PSWC());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(221, 489));
        points.add(new Point(241, 489));
        points.add(new Point(241, 427));
        points.add(new Point(132, 427));
        points.add(new Point(132, 366));
        points.add(new Point(141, 366));
        sections.add(points);
        line = new GuiLine(sections, MX3.getOut(0));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(336, 653));
        points.add(new Point(344, 653));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.ASL());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(336, 632));
        points.add(new Point(344, 632));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.LSL());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(336, 612));
        points.add(new Point(343, 612));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.ROL());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(336, 591));
        points.add(new Point(344, 591));
        sections.add(points);
        line = new GuiLine(sections, Fetch2.ROLC());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(405, 632));
        points.add(new Point(426, 632));
        points.add(new Point(426, 550));
        points.add(new Point(385, 550));
        points.add(new Point(385, 540));
        sections.add(points);
        line = new GuiLine(sections, CD2.getOut(0));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(405, 612));
        points.add(new Point(416, 612));
        points.add(new Point(416, 561));
        points.add(new Point(364, 561));
        points.add(new Point(364, 540));
        sections.add(points);
        line = new GuiLine(sections, CD2.getOut(1));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(336, 520));
        points.add(new Point(344, 520));
        sections.add(points);
        line = new GuiLine(sections, new Pin(false));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(336, 499));
        points.add(new Point(344, 499));
        sections.add(points);
        line = new GuiLine(sections, new Pin(false));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(336, 479));
        points.add(new Point(344, 479));
        sections.add(points);
        line = new GuiLine(sections, Exec1.AB7());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(336, 458));
        points.add(new Point(344, 458));
        sections.add(points);
        line = new GuiLine(sections, Exec2.PSWC());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(405, 489));
        points.add(new Point(426, 489));
        points.add(new Point(426, 427));
        points.add(new Point(313, 427));
        points.add(new Point(313, 366));
        points.add(new Point(305, 366));
        sections.add(points);
        line = new GuiLine(sections, MX4.getOut(0));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(132, 341));
        points.add(new Point(141, 341));
        sections.add(points);
        line = new GuiLine(sections, LogicalComponent.getCPUCLK());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(132, 353));
        points.add(new Point(141, 353));
        sections.add(points);
        line = new GuiLine(sections, Oper1.shr());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(312, 353));
        points.add(new Point(305, 353));
        sections.add(points);
        line = new GuiLine(sections, Oper1.shl());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(313, 341));
        points.add(new Point(305, 341));
        sections.add(points);
        line = new GuiLine(sections, Oper1.ldAB());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(69, 396));
        points.add(new Point(223, 396));
        points.add(new Point(223, 376));
        sections.add(points);
        line = new GuiLine(sections, IBUS1ToAB.getOut(0));
        gui.addLine(line);


        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(223, 331));
        points.add(new Point(223, 263));
        points.add(new Point(307, 263));
        points.add(new Point(307, 241));
        sections.add(points);
        line = new GuiLine(sections, AB.getOut(0));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(257, 171));
        points.add(new Point(266, 171));
        sections.add(points);
        line = new GuiLine(sections, Oper1.not());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(258, 187));
        points.add(new Point(266, 187));
        sections.add(points);
        line = new GuiLine(sections, Oper1.xor());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(258, 204));
        points.add(new Point(265, 204));
        sections.add(points);
        line = new GuiLine(sections, Oper1.or());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(258, 220));
        points.add(new Point(266, 220));
        sections.add(points);
        line = new GuiLine(sections, Oper1.and());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(262, 253));
        points.add(new Point(282, 253));
        points.add(new Point(282, 241));
        sections.add(points);
        line = new GuiLine(sections, new Pin(false));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(631, 263));
        points.add(new Point(385, 263));
        points.add(new Point(385, 241));
        sections.add(points);
        line = new GuiLine(sections, IBUS2ToALU.getOut(0));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(434, 220));
        points.add(new Point(426, 220));
        sections.add(points);
        line = new GuiLine(sections, Oper1.add());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(426, 204));
        points.add(new Point(434, 204));
        sections.add(points);
        line = new GuiLine(sections, Oper1.sub());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(426, 187));
        points.add(new Point(434, 187));
        sections.add(points);
        line = new GuiLine(sections, Oper1.inc());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(426, 171));
        points.add(new Point(434, 171));
        sections.add(points);
        line = new GuiLine(sections, Oper1.dec());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(409, 150));
        points.add(new Point(409, 134));
        points.add(new Point(434, 134));
        sections.add(points);
        line = new GuiLine(sections, Exec1.C8());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(346, 150));
        points.add(new Point(346, 132));
        points.add(new Point(182, 132));
        sections.add(points);
        line = new GuiLine(sections, ALUexec.getOut(0));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(169, 144));
        points.add(new Point(169, 137));
        sections.add(points);
        line = new GuiLine(sections, Oper1.ALUout1());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(158, 132));
        points.add(new Point(69, 132));
        sections.add(points);
        line = new GuiLine(sections, TSBALUout1.getOut(0));
        gui.addLine(line);


        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(631, 396));
        points.add(new Point(469, 396));
        points.add(new Point(469, 376));
        sections.add(points);
        line = new GuiLine(sections, IBUS2ToBB.getOut(0));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(379, 353));
        points.add(new Point(387, 353));
        sections.add(points);
        line = new GuiLine(sections, LogicalComponent.getCPUCLK());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(559, 353));
        points.add(new Point(551, 353));
        sections.add(points);
        line = new GuiLine(sections, Oper1.ldBB());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(469, 331));
        points.add(new Point(469, 288));
        points.add(new Point(520, 288));
        sections.add(points);
        line = new GuiLine(sections, BB.getOut(0));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(532, 293));
        points.add(new Point(532, 300));
        sections.add(points);
        line = new GuiLine(sections, Oper1.BBout2());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(544, 288));
        points.add(new Point(631, 288));
        sections.add(points);
        line = new GuiLine(sections, TSBBBout2.getOut(0));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(69, 840));
        points.add(new Point(469, 840));
        points.add(new Point(469, 819));
        sections.add(points);
        points = new ArrayList<Point>();
        points.add(new Point(233, 839));
        points.add(new Point(233, 819));
        sections.add(points);
        line = new GuiLine(sections, Bus1.IBUS1());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(143, 797));
        points.add(new Point(151, 797));
        sections.add(points);
        line = new GuiLine(sections, Oper1.ldAW());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(315, 797));
        points.add(new Point(323, 797));
        sections.add(points);
        line = new GuiLine(sections, LogicalComponent.getCPUCLK());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(233, 774));
        points.add(new Point(233, 747));
        sections.add(points);
        line = new GuiLine(sections, AW.getOut(0));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(379, 797));
        points.add(new Point(387, 797));
        sections.add(points);
        line = new GuiLine(sections, Oper1.ldBW());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(551, 797));
        points.add(new Point(559, 797));
        sections.add(points);
        line = new GuiLine(sections, LogicalComponent.getCPUCLK());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(469, 774));
        points.add(new Point(469, 747));
        sections.add(points);
        line = new GuiLine(sections, BW.getOut(0));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(212, 719));
        points.add(new Point(182, 719));
        sections.add(points);
        line = new GuiLine(sections, BW.getOut(0));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(169, 731));
        points.add(new Point(169, 724));
        sections.add(points);
        line = new GuiLine(sections, Oper1.BWout1());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(158, 719));
        points.add(new Point(69, 719));
        sections.add(points);
        line = new GuiLine(sections, TSBBWout1.getOut(0));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(439, 719));
        points.add(new Point(520, 719));
        sections.add(points);
        line = new GuiLine(sections, AW.getOut(0));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(469, 718));
        points.add(new Point(469, 667));
        points.add(new Point(520, 667));
        sections.add(points);
        line = new GuiLine(sections, AWToAWH.getOut(0));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(532, 680));
        points.add(new Point(532, 673));
        sections.add(points);
        line = new GuiLine(sections, Oper1.AWHout2());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(532, 731));
        points.add(new Point(532, 724));
        sections.add(points);
        line = new GuiLine(sections, Oper1.AWout2());
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(544, 667));
        points.add(new Point(631, 667));
        sections.add(points);
        line = new GuiLine(sections, TSBAWHout2.getOut(0));
        gui.addLine(line);

        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(544, 718));
        points.add(new Point(631, 718));
        sections.add(points);
        line = new GuiLine(sections, TSBAWout2.getOut(0));
        gui.addLine(line);


        // LABELE:
        gui.addLabel(new GuiLabel(72, 75, Bus1.IBUS1()));
        gui.addLabel(new GuiLabel(72, 810, Bus1.IBUS1()));
        gui.addLabel(new GuiLabel(638, 75, Bus1.IBUS2()));
        gui.addLabel(new GuiLabel(638, 810, Bus1.IBUS2()));
        gui.addLabel(new GuiLabel(217, 409, IBUS1ToAB.getOut(0)));
        gui.addLabel(new GuiLabel(469, 409, IBUS2ToBB.getOut(0)));
        gui.addLabel(new GuiLabel(476, 310, BB.getOut(0)));
        gui.addLabel(new GuiLabel(582, 301, TSBBBout2.getOut(0)));
        gui.addLabel(new GuiLabel(301, 279, AB.getOut(0)));
        gui.addLabel(new GuiLabel(385, 279, IBUS2ToALU.getOut(0)));
        gui.addLabel(new GuiLabel(353, 129, ALUexec.getOut(0)));
        gui.addLabel(new GuiLabel(84, 145, TSBALUout1.getOut(0)));
        gui.addLabel(new GuiLabel(483, 108, ABLToAB.getOut(0)));
        gui.addLabel(new GuiLabel(582, 104, TSBABout2.getOut(0)));
        gui.addLabel(new GuiLabel(474, 714, AW.getOut(0)));
        gui.addLabel(new GuiLabel(474, 662, AWToAWH.getOut(0)));
        gui.addLabel(new GuiLabel(582, 680, TSBAWHout2.getOut(0)));
        gui.addLabel(new GuiLabel(582, 731, TSBAWout2.getOut(0)));
        gui.addLabel(new GuiLabel(84, 732, TSBBWout1.getOut(0)));
        gui.addLabel(new GuiLabel(220, 743, AW.getOut(0)));
        gui.addLabel(new GuiLabel(240, 833, Bus1.IBUS1()));
        gui.addLabel(new GuiLabel(457, 743, BW.getOut(0)));
        gui.addLabel(new GuiLabel(477, 833, Bus1.IBUS1()));
    }

    public static Pin AB0() {
        return ABbits.getOut(0);
    }

    public static Pin AB1() {
        return ABbits.getOut(1);
    }

    public static Pin AB2() {
        return ABbits.getOut(2);
    }

    public static Pin AB3() {
        return ABbits.getOut(3);
    }

    public static Pin AB4() {
        return ABbits.getOut(4);
    }

    public static Pin AB5() {
        return ABbits.getOut(5);
    }

    public static Pin AB6() {
        return ABbits.getOut(6);
    }

    public static Pin AB7() {
        return ABbits.getOut(7);
    }

    public static Pin C8() {
        return ALUexec.getPinC8();
    }

    public static Pin ALU7() {
        return ALUbits.getOut(7);
    }

    public static Pin BB7() {
        return BBbits.getOut(7);
    }

    public static Pin AB() {
        return AB.getOut(0);
    }

    public static Pin BB() {
        return BB.getOut(0);
    }

    public static Pin ALU() {
        return ALUexec.getOut(0);
    }

    public static Pin BW() {
        return BW.getOut(0);
    }

    public static Pin AW() {
        return AW.getOut(0);
    }

    public static REG RegAB() {
        return AB;
    }

    public static REG RegBB() {
        return BB;
    }

    public static REG RegAW() {
        return AW;
    }

    public static REG RegBW() {
        return BW;
    }
}
